<?php

namespace api\modules\v1\controllers\system\base;

use Yii;
use api\controllers\OnAuthController;
use common\models\base\BcBodyParts;
use common\helpers\CommonHelper;

/**
 * Class BcBodyPartsController
 * @package api\modules\v1\controllers\base
 */
class BcBodyPartsController extends OnAuthController
{
    /**
     * @var BcBodyParts
     */
    public $modelClass = BcBodyParts::class;

    /**
     * @api {get} /v1/base/bc-body-parts/index 半舱311部位列表
     * @apiName index
     * @apiGroup BcBodyParts
     *
     */
    public function actionIndexBcBodyParts()
    {
        $params = Yii::$app->request->get();

        // 查询结果
        $data = Yii::$app->services->bcBodyParts->getList($params);

        return $data;
    }

    /**
     * @api {post} /v1/base/bc-body-parts/create 新增半舱311部位
     * @apiName create
     * @apiGroup BcBodyParts
     *
     * @apiParam {String} name              半舱311部位名称
     * @apiParam {Number} status            【1启用、0停用】
     */
    public function actionCreateBcBodyParts()
    {
        $params = Yii::$app->request->post();

        return Yii::$app->services->bcBodyParts->create($params);
    }

    /**
     * @api {post} /v1/base/bc-body-parts/update 编辑半舱311部位
     * @apiName update
     * @apiGroup BcBodyParts
     *
     * @apiParam {Number} id                半舱311部位ID
     * @apiParam {Number} status            状态【0停用 1启用】
     */
    public function actionUpdateBcBodyParts()
    {
        $params = Yii::$app->request->post();
        return Yii::$app->services->bcBodyParts->update($params);
    }


    /**
     * @api {post} /v1/base/bc-body-parts/update-status 编辑半舱311部位的状态
     * @apiName update-status
     * @apiGroup BcBodyParts
     *
     * @apiParam {Number} id                半舱311部位ID
     * @apiParam {Number} status            状态【0停用 1启用】
     */
    public function actionUpdateBcBodyPartsStatus()
    {
        $id = Yii::$app->request->post('id');
        $status = Yii::$app->request->post('status');

        return Yii::$app->services->bcBodyParts->updateStatus($id, $status);
    }

    /**
     * @api {post} /v1/base/bc-body-parts/delete 删除半舱311部位
     * @apiName delete
     * @apiGroup BcBodyParts
     *
     * @apiParam {Number} id                半舱311部位ID
     */
    public function actionDeleteBcBodyParts()
    {
        $id = Yii::$app->request->post('id');

        return Yii::$app->services->bcBodyParts->delete($id);
    }

    /**
     * @api {post} /v1/base/bc-body-parts/true-delete 删除半舱311部位
     * @apiName delete
     * @apiGroup BcBodyParts
     *
     * @apiParam {Number} id                半舱311部位ID
     */
    public function actionTrueDelete()
    {
        $id = Yii::$app->request->post('id');

        return Yii::$app->services->bcBodyParts->trueDelete($id);
    }

}